package com.ymatou.iapi.csim.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.csim.parameter.AddDiscourseCountBean;
import com.ymatou.iapi.csim.parameter.DiscourseDto;
import com.ymatou.iapi.csim.parameter.SaveOrUpdateDiscourseBean;
import com.ymatou.iapi.csim.service.AddDiscourseCountCall;
import com.ymatou.iapi.csim.service.SaveOrUpdateDiscourseCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CsimCallService;
import com.ymttest.database.model.ymt_discourse;
import com.ymttest.database.sqlwapper.CSIM.ymt_discourseWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
/**
*更新话术Count
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_AddDiscourseCount{
	private static AddDiscourseCountBean bean;
	private static AddDiscourseCountCall call;
	private Integer csId=Integer.parseInt(EnvSetup.getData("csId").toString());
	private static ymt_discourseWapper discourseWapperWapper=new ymt_discourseWapper();
	private  SaveOrUpdateDiscourseBean saveorupdatediscourseBean=new SaveOrUpdateDiscourseBean();;
	private  SaveOrUpdateDiscourseCall saveorupdatediscourseCall=new SaveOrUpdateDiscourseCall();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("更新话术Count");
	}

	@Before
	public void caseUp() {
		bean=new AddDiscourseCountBean();
		call=new AddDiscourseCountCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AddDiscourseCount_001() {
		Logger.start(true,"更新话术Count");
		try {
			saveorupdatediscourseBean.setId(TestDataManager.getRandomUUID().toString());
			saveorupdatediscourseBean.setCategoryId(TestDataManager.getRandomUUID().toString());
			saveorupdatediscourseBean.setTitle("自动化测试_"+TestDataManager.getRandomNum(5));
			saveorupdatediscourseBean.setCsId(csId);
			saveorupdatediscourseBean.setSort(1);
			saveorupdatediscourseBean.setRoleType("MAIJIA_KEFU");
			saveorupdatediscourseCall.setData(saveorupdatediscourseBean);
			saveorupdatediscourseCall.callService();	
			
			ymt_discourse discourse_old=discourseWapperWapper.selectByPrimaryKey(saveorupdatediscourseBean.getId());
			
			bean.setId(saveorupdatediscourseBean.getId());
			call.setData(bean);
			call.callService();		
			
			//验证
			ymt_discourse discourse_new=discourseWapperWapper.selectByPrimaryKey(saveorupdatediscourseBean.getId());
			
			Logger.verifyEquals("200", call.getStatus(), "验证status");
			Logger.verifyEquals("", call.getMsg(), "验证Msg");
			
			Logger.verifyEquals(true, discourse_new.getCount()>0, "验证Count");
			Logger.verifyEquals(1, discourse_new.getCount()-discourse_old.getCount(), "验证count 数量 加1");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}